package orm;

import android.provider.BaseColumns;

public class DBContract {
	
	// Prevents the FeedReaderContract class from being instantiated.
	private DBContract() {}
	
	private static final String TEXT_TYPE = " TEXT";
	private static final String INT_TYPE = " INTEGER";
	private static final String DATE_TYPE = " TEXT";
	private static final String REAL_TYPE = " REAL";
	private static final String COMMA_SEP = ",";


	/*
	 * Account, 
	 */
	public static abstract class Person implements BaseColumns {
	    public static final String TABLE_NAME = "person";
	    public static final String COLUMN_PERSON_ID = "person_id";
	    public static final String COLUMN_TITLE = "title";
	    public static final String COLUMN_FNAME = "fname";	    
	    public static final String COLUMN_LNAME = "lname";
	    public static final String COLUMN_NATION = "nation";
	    public static final String COLUMN_GENDER = "gender";
	    public static final String COLUMN_DATE_OF_BIRTH = "date_of_birth";
	    public static final String COLUMN_ANDROID_ID = "android_id";
	    public static final String COLUMN_NULLABLE = null;
	    
		public static final String CREATE_TABLE_PERSON = 
				"CREATE TABLE " + DBContract.Person.TABLE_NAME + " (" +
			    DBContract.Person.COLUMN_PERSON_ID + " INTEGER PRIMARY KEY," +
			    DBContract.Person.COLUMN_TITLE + TEXT_TYPE + COMMA_SEP + 
			    DBContract.Person.COLUMN_FNAME + TEXT_TYPE + COMMA_SEP +
			    DBContract.Person.COLUMN_LNAME + TEXT_TYPE + COMMA_SEP +
			    DBContract.Person.COLUMN_NATION + TEXT_TYPE + COMMA_SEP +
			    DBContract.Person.COLUMN_GENDER + TEXT_TYPE + COMMA_SEP +
			    DBContract.Person.COLUMN_DATE_OF_BIRTH + DATE_TYPE + COMMA_SEP + 
			    DBContract.Person.COLUMN_ANDROID_ID + TEXT_TYPE + " )";
	}
	

	/*
	 * FitnessData
	 */
	public static abstract class FitnessData implements BaseColumns {
	    public static final String TABLE_NAME = "fitnessdata";
	    public static final String COLUMN_FITNESSDATA_ID = "fitnessdata_id";
	    public static final String COLUMN_NOTES = "notes";
	    public static final String COLUMN_PERSON_FK = "integer";
	    public static final String COLUMN_DATE = "date";
	    public static final String COLUMN_HEIGHT = "height";
	    public static final String COLUMN_WEIGHT = "weight";
	    public static final String COLUMN_FITNESS = "fitness";
	    public static final String COLUMN_MOTIVATION = "motivation";
	    public static final String COLUMN_NAME_NULLABLE = null;
	    
		public static final String CREATE_TABLE_FITNESS_DATA = 
				"CREATE TABLE " + DBContract.FitnessData.TABLE_NAME + " (" +
			    DBContract.FitnessData.COLUMN_FITNESSDATA_ID + " INTEGER PRIMARY KEY," +
			    DBContract.FitnessData.COLUMN_NOTES + TEXT_TYPE + COMMA_SEP + 
			    DBContract.FitnessData.COLUMN_PERSON_FK + TEXT_TYPE + COMMA_SEP + 
			    DBContract.FitnessData.COLUMN_DATE + DATE_TYPE + COMMA_SEP + 
			    DBContract.FitnessData.COLUMN_HEIGHT + INT_TYPE + COMMA_SEP +
			    DBContract.FitnessData.COLUMN_WEIGHT + INT_TYPE + COMMA_SEP +
			    DBContract.FitnessData.COLUMN_FITNESS + INT_TYPE + COMMA_SEP +
			    DBContract.FitnessData.COLUMN_MOTIVATION + INT_TYPE + COMMA_SEP + 
			    " FOREIGN KEY ("+ DBContract.FitnessData.COLUMN_PERSON_FK +") REFERENCES "+
			    DBContract.FitnessData.TABLE_NAME + " ("+ DBContract.Person.COLUMN_PERSON_ID +")"+
			    " )";
	}
	
	/*
	 * Exercise Name
	 */
	public static abstract class ExerciseName implements BaseColumns {
	    public static final String TABLE_NAME = "exerciseName";
	    public static final String COLUMN_EXERCISENAME_ID = "exerciseName_id";
	    public static final String COLUMN_NAME = "name";
	    public static final String COLUMN_NAME_NULLABLE = null;
	    
		public static final String CREATE_TABLE_EXERCISENAME = 
				"CREATE TABLE " + DBContract.ExerciseName.TABLE_NAME + " (" +
			    DBContract.ExerciseName.COLUMN_EXERCISENAME_ID + " INTEGER PRIMARY KEY," +
			    DBContract.ExerciseName.COLUMN_NAME + TEXT_TYPE +
			    " )";
	}
	
	/*
	 * Exercise
	 */
	public static abstract class Exercise implements BaseColumns {
	    public static final String TABLE_NAME = "exercise";
	    public static final String COLUMN_EXERCISE_ID = "exercise_id";
	    public static final String COLUMN_FITNESSDATA_FK = "fitnessdata_fk";
//	    public static final String COLUMN_EXERCISE_NAME_FK = "exercise_name_fk";
	    public static final String COLUMN_EXERCISE_NAME_ENUM = "exercise_name_enum";
	    public static final String COLUMN_DATE = "date";
	    public static final String COLUMN_NAME_NULLABLE = null;
	    
		public static final String CREATE_TABLE_EXERCISE = 
				"CREATE TABLE " + DBContract.Exercise.TABLE_NAME + " (" +
			    DBContract.Exercise.COLUMN_EXERCISE_ID + " INTEGER PRIMARY KEY," +
			    DBContract.Exercise.COLUMN_FITNESSDATA_FK + INT_TYPE + COMMA_SEP +
//			    DBContract.Exercise.COLUMN_EXERCISE_NAME_FK + INT_TYPE + COMMA_SEP + 
			    DBContract.Exercise.COLUMN_EXERCISE_NAME_ENUM + TEXT_TYPE + COMMA_SEP + 
			    DBContract.Exercise.COLUMN_DATE + DATE_TYPE +
//			    " FOREIGN KEY ("+ DBContract.Exercise.COLUMN_FITNESSDATA_FK +") REFERENCES "+
//			    DBContract.FitnessData.TABLE_NAME + " ("+ DBContract.FitnessData.COLUMN_FITNESSDATA_ID +")"+
//			    " FOREIGN KEY ("+ DBContract.Exercise.COLUMN_EXERCISE_NAME_FK +") REFERENCES "+
//			    DBContract.ExerciseName.TABLE_NAME + " ("+ DBContract.ExerciseName.COLUMN_EXERCISENAME_ID +")"+
			    " )";
	}
	
	/*
	 * Unit
	 */
	public static abstract class Set implements BaseColumns {
	    public static final String TABLE_NAME = "unit";
	    public static final String COLUMN_UNIT_ID = "unit_id";
	    public static final String COLUMN_UNIT_NR = "fitnessdata_fk";
	    public static final String COLUMN_VALUE_INT = "value_int";
	    public static final String COLUMN_VALUE_TIME = "value_time";
	    public static final String COLUMN_VALUE_WEIGHT = "value_weight";
	    public static final String COLUMN_EXERCISE_FK = "exercise_fk";
	    public static final String COLUMN_NAME_NULLABLE = null;
	    
		public static final String CREATE_TABLE_UNIT = 
				"CREATE TABLE " + DBContract.Set.TABLE_NAME + " (" +
			    DBContract.Set.COLUMN_UNIT_ID + " INTEGER PRIMARY KEY," +
			    DBContract.Set.COLUMN_UNIT_NR + INT_TYPE + COMMA_SEP + 
			    DBContract.Set.COLUMN_VALUE_INT + INT_TYPE + COMMA_SEP + 
			    DBContract.Set.COLUMN_VALUE_TIME + DATE_TYPE + COMMA_SEP + 
			    DBContract.Set.COLUMN_VALUE_WEIGHT + INT_TYPE + COMMA_SEP + 
			    DBContract.Set.COLUMN_EXERCISE_FK + INT_TYPE + COMMA_SEP +
			    " FOREIGN KEY ("+ DBContract.Set.COLUMN_EXERCISE_FK +") REFERENCES "+
			    DBContract.Exercise.TABLE_NAME + " ("+ DBContract.Exercise.COLUMN_EXERCISE_ID +") "+
			    " )";
	}
}
